package com.chen.base.property;

import com.chen.base.utils.ConvertUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: ~龙~
 * @date: 2023/8/11 9:16
 **/
@Data
@Component
@ConfigurationProperties(prefix = "thread-pool")
public class ThreadPoolProperties {

    /**
     * 线程池集合
     */
    private List<ThreadPool> list;

    /**
     * 获取线程池配置实体
     * @param key key
     */
    public ThreadPool getThreadPool(String key){
        return ConvertUtil.listToMap(list, ThreadPool::getName).get(key);
    }
}
